import { HttpClient } from "@angular/common/http";
import { Component, OnInit } from "@angular/core";
import { NavController } from "@ionic/angular";

@Component({
  selector: "app-ranking",
  templateUrl: "./ranking.page.html",
  styleUrls: ["./ranking.page.scss"],
})
export class RankingPage implements OnInit {
  constructor(public http: HttpClient, public router: NavController) {}

  res: Result;
  books: Book;
  rank = 0;
  ngOnInit(): void {
    let url = "http://xiaoshuogebed.applinzi.com/male";

    this.http.get(url).subscribe((res: Result) => {
      this.res = res;
    });
    let bookUrl = "http://xiaoshuogebed.applinzi.com/book?mid=1";
    this.http.get(bookUrl).subscribe((result: Book) => {
      this.books = result;
    });
  }
  showbooks(mid) {
    let url = "http://xiaoshuogebed.applinzi.com/book?mid=" + mid;
    this.http.get(url).subscribe((result: Book) => {
      this.books = result;
    });
  }
}
interface Result {
  code: number;
  message: string;
  results: Results[];
}
interface Results {
  mid: number;
  title: string;
  cover: string;
}
interface Book {
  code: number;
  message: string;
  results: Books[];
}
interface Books {
  author: string;
  bid: number;
  cover: string;
  latelyFollower: string;
  majorCate: string;
  male_id: number;
  minorCate: string;
  shortIntro: string;
  title: string;
}
